package com.cjy.runnable.demo5;

/**
 * @author Cheng JiYe
 * @description:
 * @date 2021/4/25 0:57
 */
public class ThreadInterruptDemo {
  public static void main(String[] args) {
    // 实例化Runnable子类对象
    MyThread mt = new MyThread();
    // 实例化Thread对象
    Thread t = new Thread(mt, "线程");
    t.start(); // 启动线程
    try {
      // 线程休眠2秒
      Thread.sleep(2000);
    } catch (InterruptedException e) {
      System.out.println("3、休眠被终止");
    }
    t.interrupt(); // 中断线程执行
  }
}
